<?
			$cSql = "SELECT Lib.bBaja, Lib.cGeografico, Lib.cTituloNoControlado, Lib.ncLibro, Lib.cContinua, Lib.cContinuada, Lib.cEjemplares, Lib.cdLibro, Lib.nEdicion, Lib.cUbicacion, Lib.nRegistro, Lib.cPalabrasPersonaClave, Lib.cPalabrasGeograficoClave,Lib.cPalabrasClave, Lib.cqEjemplares, Lib.cISBN, Lib.cISSN, Lib.cSerie, Lib.cEdicion, Lib.cPeriodoPublicacion, Lib.cDescripcionFisica, Lib.cTituloUniforme, Lib.cTituloVariacion, Lib.cTituloCongreso, Lib.cFrecuencia,
							cdTema, cdTipoFormato, cdLugar, cdTipoContenido, cDirectorio, cdTipoMaterial
							FROM btLibro AS Lib
							LEFT JOIN bcTema AS Tem
								ON Tem.ncTema = Lib.ncTema
							LEFT JOIN bcTipoFormato AS TFo
								ON TFo.ncTipoFormato = Lib.ncTipoFormato
							LEFT JOIN btLugar AS Lug
								ON Lug.ncLugar = Lib.ncLugar
							LEFT JOIN bcTipoContenido AS TCo
								ON TCo.ncTipoContenido = Lib.ncTipoContenido
							LEFT JOIN bcTipoMaterial AS TMa
								ON TMa.ncTipoMaterial = Lib.ncTipoMaterial
						";
		$ncLibro = getParam('ncLibro');
		$cSql .= " WHERE Lib.ncLibro = $ncLibro ";
		
		$this->oRecordset = $this->oDatabase->recordset($cSql );
		echo "<h2>Ficha</h2>";
		/// Ciclo por cada registro
		$this->oRecordset->moveNext() ;
		// Arma el array de personas
		$aMatrix = $this->oDatabase->getMatrix("SELECT LPe.ncRol, cdRol, cNombre, cApellido FROM btPersona as Per JOIN btLibroPersona as LPe ON LPe.ncPersona = Per.ncPersona JOIN bcRol as Rol ON LPe.ncRol = Rol.ncRol WHERE ncLibro=" . $this->oRecordset->aFields[ncLibro] . " ORDER BY LPe.ncRol");
		foreach( $aMatrix as $aRow)
		{
			if ( $aRow[ncRol] == 1 ) 
				$cAutores .= $aRow[cApellido] . ', ' . $aRow[cNombre] . '; ';
			else
				$aPersonas[$aRow[cdRol]] = $aRow[cApellido] . ', ' . $aRow[cNombre] . '; ';
		}
		// Arma el array de notas
		$aNotas = $this->oDatabase->getKeyArray("SELECT cdTipoNota, cdNota FROM btLibroNota as LNo JOIN bcTipoNota as TNo ON TNo.ncTipoNota = LNo.ncTipoNota WHERE ncLibro=" . $this->oRecordset->aFields[ncLibro] . " ORDER BY LNo.ncTipoNota");
		 
		$cdLibro = $this->oRecordset->aFields[cdLibro];		
		echo "<div style='float: left;width: 215px; padding: 5px;margin-right: 10px;background-color: #f0f0f0'>";
		echo "<div style='font-size: 15px;font-weight: bold' >" . $cdLibro ."</div>" ;
		echo "<div style='margin-bottom: 10px' >" . substr($cAutores,0,-2) ."</div>" ;
		foreach( $aPersonas as $cdRol => $cPersonas )
		{
			echo "<div><span style='font-weight: bold'>$cdRol:</span> " . substr($cPersonas,0,-2) ."</div>" ;
		}					
		foreach( $aNotas as $cdTipoNota => $cdNota )
		{
			echo "<div><span style='font-weight: bold'>$cdTipoNota:</span> " . nl2br($cdNota) ."</div>" ;
		}					
		if ( $this->oRecordset->aFields[cdTipoFormato] ) echo "<div><span style='font-weight: bold'>Formato:</span> " . $this->oRecordset->aFields[cdTipoFormato] ."</div>" ;
		if ( $this->oRecordset->aFields[cdLugar] ) echo "<div><span style='font-weight: bold'>Lugar:</span> " . $this->oRecordset->aFields[cdLugar] ."</div>" ;
		if ( $this->oRecordset->aFields[cdTipoContenido] ) echo "<div><span style='font-weight: bold'>Tipo de contenido:</span> " . $this->oRecordset->aFields[cdTipoContenido] ."</div>" ;
		if ( $this->oRecordset->aFields[cdTipoMaterial] ) echo "<div><span style='font-weight: bold'>Tipo material:</span> " . $this->oRecordset->aFields[cdTipoMaterial] ."</div>" ;
		//if ( $this->oRecordset->aFields[cdEditorial] ) echo "<div><span style='font-weight: bold'>Editorial:</span> " . $this->oRecordset->aFields[cdEditorial] ."</div>" ;
		if ( $this->oRecordset->aFields[cdTema] ) echo "<div><span style='font-weight: bold'>Tema:</span> " . $this->oRecordset->aFields[cdTema] ."</div>" ;
		//nEdicion, cUbicacion, nRegistro, cPalabrasClave, nqEjemplares, cSerie, cEdicion, cPeriodoPublicacion, cDescripcionFisica, cTituloUniforme, cTituloVariacion, cTituloCongreso, cFrecuencia	
		if ( $this->oRecordset->aFields[nEdicion] ) echo "<div><span style='font-weight: bold'>Nro de edici&oacute;n:</span> " . $this->oRecordset->aFields[nEdicion] ."</div>" ;
		if ( $this->oRecordset->aFields[cEdicion] ) echo "<div><span style='font-weight: bold'>A&ntilde;o de edici&oacute;n:</span> " . $this->oRecordset->aFields[cEdicion] ."</div>" ;
		if ( $this->oRecordset->aFields[nqEjemplares] ) echo "<div><span style='font-weight: bold'>Ejemplares:</span> " . $this->oRecordset->aFields[nqEjemplares] ."</div>" ;
		if ( $this->oRecordset->aFields[cDescripcionFisica] ) echo "<div><span style='font-weight: bold'>Descripci&acute;on f&iacute;sica:</span> " . nl2br($this->oRecordset->aFields[cDescripcionFisica]) ."</div>" ;
		echo "</div>";
	
	$aFotos = armarDirectorio( PATH_FILES . 'imagenes_libro/' . $this->oRecordset->aFields[cDirectorio], 'JPG', false );
		//$aFotos = $this->oDatabase->getMatrix("SELECT cArchivo, cTitulo FROM btLibroFoto WHERE ncLibro=" . $this->oRecordset->aFields[ncLibro] . " ORDER BY nOrden");
		
		echo "<div style='float: left;width: 300px;'>";
		echo "<img id='imgPreview' style='border: none;' src='files/imagenes_libro/" . $this->oRecordset->aFields[cDirectorio] . '/' .$aFotos[0][name] . '.' . $aFotos[0][extension]."'  />";
		echo "<div style='float: left;width: 300px;height: 15px' id='epigrafe'>" . (substr($aFoto[name],0, 3) != 'IMG' ? $aFoto[name]: '' ) ."</div>";

		echo "<div onmouseout=\"photogalleryMouseoutEvent(event, this, 'photogallery_libro');\" style='width: 300px;'>
					<div style=\"clear: none; overflow:\">
						<div style=\"float: left; width: 25px; height: 45px; padding-top: 15px;\"><a href=\"javascript://void(0);\" onclick=\"return photogalleryMove('photogallery_libro', 40);\"><img src=\"imagenes/flecha_photo_izq.gif\" width=\"21\" height=\"21\" style=\"border: none\" alt=\"<\" /></a></div>
						<div onmouseout=\"photogalleryMouseoutEvent(event, this, 'photogallery_libro');\" style=\"margin: 5px 0px; float: left; height: 45px; width: 240px;\">
							<div onmouseout=\"photogalleryMouseoutEvent(event, this, 'photogallery_libro');\"  onmousemove=\"return photogalleryMousemoveEvent(event, this, 'photogallery_libro');\"   style=\"margin: 0; float: left; padding: 0; width: 230px; overflow: hidden; position: absolute; margin-left: 2px;	\" >
								<div style=\"position: relative; white-space: nowrap;\" id=\"photogallery_libro\">
									<ul id=\"photogallery_libro_interior\"  style=\"list-style-type: none; margin: 0px; padding: 0px\">";
									foreach( $aFotos as $aFoto )
									{
										$cFoto =  "files/imagenes_libro/" . $this->oRecordset->aFields[cDirectorio] . '/' .$aFoto[name] . '.' . $aFoto[extension];
										$cEpigrafe =  substr($aFoto[name],0,3) != 'IMG' ? $aFoto[name]: '';
										echo "<li onmousedown=\"return false;\" onclick=\"photogalleryView( 'imgPreview',  '". URL_ROOT. $cFoto."' );o=document.getElementById('epigrafe'); o.innerHTML='" . $cEpigrafe . "' \" style=\"display: inline; margin-left: 2px\" ><img  style='border: #c9cdd3 solid 1px; width:30px; height:45px' src=\"" . $cFoto . "\"  /></li>"; //resizeImage( $cFoto, 30, 45, PATH_ROOT, URL_ROOT) 
									}
		echo "
									</ul>
								</div>
							</div>
						</div>
						<div style=\"float: left; width: 25px;  height: 45px;padding-top: 15px;\"><a href=\"javascript://void(0);\" onclick=\"return photogalleryMove( 'photogallery_libro', -40  );\"><img src=\"imagenes/flecha_photo_der.gif\" width=\"21\" height=\"21\" style=\"border: none\" alt=\">\" /></a></div>
					</div>
				</div>";		
		echo "</div>";

?>